/*
 * @Author: thl t15945324431@163.com
 * @Date: 2024-05-13 16:26:23
 * @LastEditors: thl t15945324431@163.com
 * @LastEditTime: 2024-05-13 17:13:28
 * @FilePath: \cw_web\gl\src\App.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import React from "react";
import KeepAlive, { AliveScope, useAliveController } from 'react-activation'
import {
  HashRouter as Router,
  Route,
  Switch,
  Redirect,
} from "react-router-dom";
import CacheRoute, { CacheSwitch } from 'react-router-cache-route'
import loadable from "./utils/loadable";
import "./style/reset.less";
import "animate.css";
import "./style/base.less";
import "./style/App.less";
import "antd/dist/antd.less";
import "@/font/iconfont.css";
import { Divider } from "antd";
import store from '@/store/store'
import img500 from '@/assets/images/500.png'
// 公共模块
const DefaultLayout = loadable(() =>
  import(/* webpackChunkName: 'default' */ "./containers")
);
// 基础页面
const View404 = loadable(() =>
  import(/* webpackChunkName: '404' */ "./views/others/404")
);
const View500 = loadable(() =>
  import(/* webpackChunkName: '500' */ "./views/others/500")
);
const Login = loadable(() =>
  import(/* webpackChunkName: 'login' */ "./views/login/Login")
);

class App extends React.Component {
  constructor() {
    super()
    this.state = {
      hasError: false
    }
  }
  // static getDerivedStateFromError(error) {
  //   console.error(error);
  //   // 更新 state 使下一次渲染能够显示降级后的 UI
  //   return { hasError: true };
  // }
  componentDidMount() {
    // setTimeout(() => {
    //   store.dispatch({
    //     type: 'IntervalPageActionTime'
    //   })
    // }, 3000)
  }
  render() {

    return (
      <Router>
        <CacheSwitch>
          <Route path="/login" component={Login} />
          <Route component={DefaultLayout} />
          <Route path="/500" component={View500} />
          <Route path="/404" component={View404} />
          <CacheRoute path="/" exact render={() => <Redirect to="/home" />} />
          <Route path="/" exact render={() => <Redirect to="/home" />} />
        </CacheSwitch>
      </Router>
    )
  }
}
// const App = () => (
//   <Router>
//     <Switch>
//       <CacheRoute path="/" exact render={() => <Redirect to="/home" />} />
//       <Route path="/login" component={Login} />
//       <Route path="/" exact render={() => <Redirect to="/home" />} />
//       <Route path="/500" component={View500} />
//       <Route path="/404" component={View404} />
//       <Route component={DefaultLayout} />
//     </Switch>
//   </Router>

// );

export default App;
